#include "CFPS.h"
 
CFPS CFPS::FPSControl;
 
CFPS::CFPS()
{
    OldTime     = 0;
    LastTime    = 0;
    SpeedFactor = 0;
    Frames      = 0;
    NumFrames   = 0;
}
 
void CFPS::OnLoop()
{
    int currentTicks = SDL_GetTicks();
    if(OldTime + 1000 < currentTicks)
    {
        OldTime = currentTicks;
        NumFrames = Frames;
        Frames = 0;
    }
    SpeedFactor = ((currentTicks - LastTime) / 1000.0f) * 32.0f;
    LastTime = currentTicks;
    Frames++;
}
 
int CFPS::GetFPS()
{
    return NumFrames;
}
 
float CFPS::GetSpeedFactor()
{
    return SpeedFactor;
}